import { ref } from 'vue'
type CallBackType = (item?: any) => void
export function usePageModal(newCb?: CallBackType, editCb?: CallBackType) {
  // 新建和编辑
  const pageModalRef = ref()
  const defualtInfo = ref({})
  const handleNewClick = () => {
    defualtInfo.value = {}
    if (pageModalRef.value) {
      pageModalRef.value.DialogVisible = true //显示编辑组件
    }
    newCb && newCb()
  }
  const handleEditClick = (item: any) => {
    console.log('编辑')
    defualtInfo.value = { ...item }
    if (pageModalRef.value) {
      pageModalRef.value.DialogVisible = true
    }
    editCb && editCb(item)
  }
  return [pageModalRef, defualtInfo, handleNewClick, handleEditClick]
}
